<?php

use magein\sms\Send;
use magein\sms\SmsException;
use magein\utils\Result;

if (!function_exists('sms_send')) {
    /**
     * @return Send
     */
    function sms_send(): Send
    {
        return app('sms')->send;
    }
}

if (!function_exists('sms_code')) {
    /**
     * @param $data
     * @return Result
     */
    function sms_code($data): Result
    {
        try {
            $result = sms_send()->code($data);
        } catch (SmsException $smsException) {
            $result = $smsException->toResult();
        }
        return $result;
    }
}
